<div class="coreBlocks form">
    <?php echo $this->Form->create('CoreBlock'); ?>
    <fieldset>
        <legend><?php echo __('Edit Core Block'); ?></legend>
        <?php
        echo $this->Form->input('id');
        echo $this->Form->input('core_sites_id');
        echo $this->Form->input('cobl_name', array(
            'type'=>'select', 
            'options'=>$blocksArray,
            'onchange' => "javascript:loadBlockForm($(this));", 
            'id'=>'cobl_name'
            ));
        echo $this->Form->input('cobl_description');
        echo $this->Form->input('cobl_position', array('options' => array('t' => __('Top'), 'l' => __('Left'), 'c' => __('Center'), 'r' => __('Right'), 'b' => __('Bottom'))));
        echo $this->Form->input('cobl_sequence', array('type' => 'number'));
        echo $this->Form->input('cobl_template', array('type'=>'select', 'options' => $layouts, 'empty' => true));
        //echo $this->Form->input('cobl_attributes');
        echo $this->Form->input('cobl_status', array('options' => array('a' => __('Active'), 'i' => __('Inactive')), 'default' => 'a'));
        echo $this->CoreForm->checkboxSelectAll('CoreModule.como_id', array(
            'label' => 'Módulo',
            'type' => 'select',
            'multiple' => 'checkbox',
            'options' => $modules,
            'selected' => $modulesSelected
        ));
        echo $this->CoreForm->checkboxSelectAll('CoreGroupsBlock.core_groups_id', array(
            'label' => __('Groups'),
            'type' => 'select',
            'multiple' => 'checkbox',
            'options' => $groups,
            'selected' => $groupsSelected
        ));
        //var_dump($selected);
        ?>
        <label for="block_form"><?php echo __('Block Form'); ?></label><div id="block_form"></div>
    </fieldset>
    <?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
    <h3><?php echo __('Actions'); ?></h3>
    <ul>

        <li><?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $this->Form->value('CoreBlock.id')), null, __('Are you sure you want to delete # %s?', $this->Form->value('CoreBlock.id'))); ?></li>
        <li><?php echo $this->Html->link(__('List Core Blocks'), array('action' => 'index')); ?></li>
        <li><?php echo $this->Html->link(__('List Core Sites'), array('controller' => 'core_sites', 'action' => 'index')); ?> </li>
        <li><?php echo $this->Html->link(__('New Core Sites'), array('controller' => 'core_sites', 'action' => 'add')); ?> </li>
    </ul>
</div>
<script>
    function loadBlockForm(input){
        $('#block_form').html('<?php echo __('Loading...'); ?>');
        url = input.find(":selected").val();
        var pices = url.split('/');
        $('#block_form').load('../'+pices[0]+'/form_'+pices[1]+'/'+<?php echo $this->Form->value('CoreBlock.id');?>); 
    }
    loadBlockForm($('#cobl_name'));
</script>
